package com.lagou;

import com.lagou.bean.ConsumerComponent;
import org.apache.dubbo.config.spring.context.annotation.EnableDubbo;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;

import java.io.IOException;
import java.security.SecureRandom;


public class AnnotationConsumerMain {
    public static void main(String[] args) throws IOException, InterruptedException {
        AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(ConsumerConfiguration.class);
        context.start();
        System.out.println("consumer启动成功！");
        ConsumerComponent service = context.getBean(ConsumerComponent.class);

        System.in.read();

        while (true) {
            Thread.sleep(10);
            new Thread(new Runnable() {
                @Override
                public void run() {
                    String   msgA =  service.methodA("A",0);
                    String   msgB =  service.methodB("B",0);
                    String   msgC =  service.methodC("C",0);
                }
            }).start();
        }
    }

    @Configuration
    @PropertySource("classpath:/dubbo-consumer.properties")
    //@EnableDubbo(scanBasePackages = "com.lagou.bean")
    @ComponentScan("com.lagou.bean")
    @EnableDubbo
    static class ConsumerConfiguration {

    }
}
